var URL_BUYER_INFO = '/buyer/person_info';
var URL_BUY_UPDATE = '/buyer/buyer_reg';
var buyer;
var optList = ['工商银行', '农业银行', '建设银行', '中国银行', '招商银行', '其他银行'];


//页面初始化回调
function initPage(pg, id, cb) {
  if(pg.matches(id)) cb()
}


$(init);

function init() {
    $('body').on('click', 'ons-list-item#update-buyer', function () {  navPushPage('/mobile-views/_me/update-buyer.html') })
             .on('click', 'ons-list-item#change-pwd', function () { navPushPage('/mobile-views/_me/change-pwd.html') })
             .on('click', 'ons-list-item#withdraw', function () { navPushPage('/mobile-views/_me/withdraw.html') })
             .on('click', 'ons-list-item#appeal', function () { navPushPage('/mobile-views/_me/appeal.html') })
             .on('click', 'ons-list-item#vip-pay', function () { navPushPage('/mobile-views/_me/vip-pay.html') })
             .on('click', 'ons-list-item#real-name', function () { navPushPage('/mobile-views/_me/real-name.html') })
             .on('click', 'ons-list-item#bind-bank', function () { navPushPage('/mobile-views/_me/bind-bank.html') })
             .on('click', 'ons-list-item#bind-tb', function () { navPushPage('/mobile-views/_me/bind-tb.html') })
             .on('click', 'ons-list-item#new-guide', function () { navPushPage('/mobile-views/_me/new-guide.html') });

    $('body').on('click',  'ons-list-item#myOrders', myOrdersClick)
             .on('click',  'ons-tab.list-btn',       myOrdersIndex)
             //-- 绑定银行卡 -------------------------------------------//
             .on('click',  '#bind-card-btn',         doBindCard)
             //-- 实名认证 -------------------------------------------//
             .on('change', '#up-card-f',             uploadImg)
             .on('change', '#up-card-b',             uploadImg)
             .on('click',  '#real-name-btn',         doRealName)
             //-- 绑定淘宝 -------------------------------------------//
             .on('change', '#tb-account',            uploadImg)
             .on('change', '#tb-level',              uploadImg)
             .on('change', '#tb-huabei',             uploadImg)
             .on('click',  '#bind-tb-btn',           doBindTB)
             //-- VIP充值 -------------------------------------------//
             .on('click',  '#vip-banalce-btn',       doVipBalance)
             .on('change', '#vipBankTrans',          uploadImg)
             .on('click',  '#vip-bank-btn',          doVipBank)
             .on('click',  '#vip-bank-list-tab',     doRefVipBankList)
             //-- 资金提现 -------------------------------------------//
             .on('change', '#account-type',          doRenderMoney)
             .on('click',  '#withdraw-btn',          doWithdraw)
            //-- 微信保存 -------------------------------------------//
             .on('click', '#wechat-btn',             wechatSave);


    copyQQ();

    document.addEventListener('init', function (event) {
        var page = event.target;
        //-- 初始化 用户信息 -------------------------------------------//
        initPage(page, '#update-buyer', initUpdateBuyer)
        //-- 初始化 绑定银行卡 -------------------------------------------//
        initPage(page, '#bind-bank',    initBindBank);
        //-- 初始化 实名认证 -------------------------------------------//
        initPage(page, '#real-name',    initRealName);
        //-- 初始化 绑定淘宝 -------------------------------------------//
        initPage(page, '#bind-tb',      initBindTB);
        //-- 初始化 VIP本金充值 -------------------------------------------//
        initPage(page, '#vip-balance',  initVipBanance);
        //-- 初始化 VIP转账充值 -------------------------------------------//
        initPage(page, '#vip-bank',     initVipBank);
        //-- 初始化 VIP转账列表 -------------------------------------------//
        initPage(page, '#vip-bank-list',initVipBankList);
        //-- 初始化 资金提现 -------------------------------------------//
        initPage(page, '#withdraw-main',initWithdrawMain);
        //-- 初始化 资金提现列表 -------------------------------------------//
        initPage(page, '#withdraw-list',initWithdrawList);

    });
}

function initWithdrawList() {
  var pageData = {pageIndex: 0, pageSize: 10}
  promiseTmpl('GET', '/mobile-tmpl/withdraw-list-render.tmpl', ['/buyer/buyer_withdraw_list', encodeQuery(pageData)].join('?'),null, function (r,ret){
    if(ret.data.length === 0) return;
    else {
        $('ons-card.nothing-card').css('display', 'none');
        $("#withdraw-list .list-render").empty();
        $("#withdraw-list .list-render").append($.templates(r).render(ret, rdHelper));
    }
  });
}

function doWithdraw() {
    // 若未绑定银行卡 提示
  if(cookie('bankcardState') !== 1){
      notifyInfo('请先完成银行卡绑定！');
      navPopPage();
      return;
  }

  var type = parseInt($("#sel-account-type option:selected").val())
  var money = parseInt($('#withdraw-money').val());
  var cost;

  if (type === 0) {
    if (money < 200) {
      return errorInfo('提现金额必须大于200！');
    } else if ( money > _withdraw.balance.toFixed(2) ) {
      return errorInfo('提现超出余额！');
    }

    if (money<500) {
      cost = (money * 0.01).toFixed(2)
    }else if((money>=500)&&(money<=1999)) {
      cost = 5
    }else if( money >=2000) {
      cost = 0
    }
  }


  if (type === 1) {

    if (money <100){
      return errorInfo('佣金提现必须大于等于100！');
    } else if (money%100 !== 0) {
      return errorInfo('佣金提现必须是100的倍数！');
    } else if (money > _withdraw.servicefee.toFixed(2) ) {
      return errorInfo('提现超出余额！');
    }

    if (money<2000) {
      cost = (money * 0.01).toFixed(2)
    }else if(money>=2000) {
      cost = 0
    }
  }

  confirm(`<span class="font-red">本次提现金额${money}元，扣取手续费${cost}元</span>`, function (){
    var obj = {
      // mobile: parseInt($('#buyer-mobile').val()),
      buyerName: $('#buyer-name').val(),
      // buyerBankId:$('#bank-name').val(),
      toAccount: $('#bank-account').val(),
      withdrawMoney: parseInt($('#withdraw-money').val()),
    };

    // console.log(obj);
    var url = (type == 0)?URL_BUY_WITHDRAW:URL_BUY_FEE_WITHDRAW;
    promise('POST', url, JSON.stringify(obj), function (e){
      notifyInfo('提现成功！请等待审核完毕！');
      initWithdrawMain();
    }, null);
  }, null);
}


function initWithdrawMain() {

  $("#buyer-mobile").val( cookie("mobile"));
  $("#buyer-name").val( cookie("name"));
  $("#bank-account").val( cookie2('bankNo', 'buyerBankList') );
  $("#bank-name").val(  optList[cookie2('bank', 'buyerBankList')] );

  promise('GET', URL_BUY_BALANCE, null, function(e){
    _withdraw = e;
    $("#with-amount").val(`${_withdraw.balance} 元`)
  }, null);
}


function doRenderMoney() {
  var type = parseInt($("#sel-account-type option:selected").val())
  if (type === 0) {
    $("#with-amount").val(`${_withdraw.balance} 元`)
    $(".m-info-b").show()
    $(".m-info-s").hide()

  }else{
    $("#with-amount").val(`${_withdraw.servicefee} 元`)
    $(".m-info-b").hide()
    $(".m-info-s").show()
  }
}

//刷新VIP充值
function doRefVipBankList() {
  initVipBankList()
}

//显示VIP充值记录
function initVipBankList() {

  var obj = {
    pageIndex: 0,
    pageSize: 99,
  }




  promiseTmpl3('GET',
    '/mobile-tmpl/vip-bank-list-render.tmpl',
    '/mobile-tmpl/vip-bank-list-render2.tmpl',
    [URL_MEMBERSHIP_LIST, encodeQuery(obj)].join('?'),
    '/buyer/vip_record_list',
    function (r1, r2, ret1,ret2){
        console.log(ret1.data.length);
        console.log(ret2.data.length);
      if ((ret1.data.length === 0) && (ret2.data.length === 0)) return;
      else{
        $('ons-card.nothing-card').css('display', 'none');
        $("#vip-bank-list .list-render").empty();
        $("#vip-bank-list .list-render").append($.templates(r1).render(ret1, rdHelper));
        $("#vip-bank-list .list-render").append($.templates(r2).render(ret2, rdHelper));
      }
  })



}

//VIP转账充值
function doVipBank() {
  if ( $('#transferPerson').val() === '' ) {
    notifyInfo('请填写汇款人姓名');return;
  }

  if ( $('#fromAccount').val() === '' ) {
    notifyInfo('请填写汇款人账户');return;
  }

  if ( typeof($('#vipBankTrans').attr('picurl')) === 'undefined' ) {
    notifyInfo('请上传汇款截图');return;
  }

  data = {
    membershipFeeId:$("#sel-vip-btype").val(),
    toAccount: $("#toAccount").val(),
    transferMoney:  $('#sel-vip-btype option:selected').attr('pay'),
    bankName: $('#sel-vip-bank').val(),
    transferPerson: $('#transferPerson').val(),
    fromAccount: $('#fromAccount').val(),
    remark: '',
    picture: $('#vipBankTrans').attr('picurl'),
    transferType: 1
  }
  console.log(JSON.stringify(data));
  promise('POST', URL_MEMBERSHIP_TRANSFER, JSON.stringify(data), function(e){
    notifyInfo('提交银行汇款成功！请等待审核！');
  }, null)
}

//VIP充值
function doVipBalance() {
  confirm('请确认本金充值！', function(){
    var obj = { membershipFeeId: parseInt($("#sel-vip-type").val()) }
    promise('GET', ['/buyer/pay_membershipfee', encodeQuery(obj)].join('?'), null, function(e){
      notifyInfo('充值成功！');
      initVipBanance()
    }, null);
  })
}

//初始化银行充值
function initVipBank() {
  //初始化会员类型
  promise('GET', URL_MEMBERSHIP_FEE_TYPE, null, function(e){
    $("#sel-vip-btype").empty();
    $.each(e, function(index, val) {
        $("#sel-vip-btype").append(`<option value="${val.id}" pay="${val.money}">${val.money}元 | ${val.name}</option>`);
    })
  }, null);
}

//初始化本金充值页面
function initVipBanance() {

  //显示本金余额
  promise('GET','/buyer/buyer_balance',null, function(e){
    $("#vip-balance-money").text( fix(e.balance) );
  }, null)

  //初始化会员类型
  promise('GET', URL_MEMBERSHIP_FEE_TYPE, null, function(e){
    $("#sel-vip-type").empty()
    $.each(e, function(index, val) {
        $("#sel-vip-type").append(`<option value="${val.id}">${val.money}元 | ${val.name}</option>`);
    })
  }, null);
}




//冻结绑定淘宝输入
function forzenTaobaoInfo() {
  $('#account').attr('readonly',true)

  $('#receiver').attr('readonly',true)
  $('#receiveMobile').attr('readonly',true)
  $('#receiveAddress').attr('readonly',true)
  $('#acountLevel').attr('disabled',true)
  $('#choose-province').attr('disabled',true)
  $('#choose-city').attr('disabled',true)
  $('#choose-district').attr('disabled',true)

  $('.ons-upload').hide()
  $('#bind-tb-btn').hide()
}


//初始化绑定淘宝
function initBindTB() {
  $('#choose-province').distpicker();

  promise('GET', URL_BUY_INFO, null, function(e){
    console.log(e);
    status = e.taobaoList[0] && e.taobaoList[0].approve >=0 ? e.taobaoList[0].approve : -1;
    // 未绑定
    if ( status === -1 ) return;


    // 审核不通过
    if( e.taobaoList[0].approve === 2) {
        $('ons-card#approve-reason').css('display', 'block');
        $('#approve-status span').text( e.taobaoList[0].approveString );
        $('ons-card#approve-reason span.reason').text(e.taobaoList[0].approveReason);

        $('#account').val( e.taobaoList[0].acount )
        $('#receiver').val( e.taobaoList[0].receiver )
        $('#receiveMobile').val( e.taobaoList[0].receiveMobile )
        $('#receiveAddress').val( e.taobaoList[0].receiveAddress )
        $('#acountLevel').val(e.taobaoList[0].acountLevel)
        document.querySelector('#baitiaoStart').checked = e.taobaoList[0].baitiaoStart;

        $(`#choose-province`).val(`${e.taobaoList[0].receiveProvince}`);
        $("#choose-province select").trigger("change");
        $(`#choose-city`).val(`${e.taobaoList[0].receiveCity}`);
        $("#choose-city select").trigger("change");
        $(`#choose-district`).val(`${e.taobaoList[0].receiveCountry}`);

        $('#tb-account').attr('picurl',IMG_PREFIX+ e.taobaoList[0].mysiteImg).next().attr('src', IMG_PREFIX+e.taobaoList[0].mysiteImg)
        $('#tb-level').attr('picurl',IMG_PREFIX+ e.taobaoList[0].myacountImg).next().attr('src', IMG_PREFIX+e.taobaoList[0].myacountImg)
        $('#tb-huabei').attr('picurl',IMG_PREFIX+ e.taobaoList[0].baitiaoImg).next().attr('src', IMG_PREFIX+e.taobaoList[0].baitiaoImg)
    }

    // 审核通过 || 审核中
    if ( e.taobaoList[0].approve === 1 || e.taobaoList[0].approve === 0)
    {
        $('#approve-status span').text( e.taobaoList[0].approveString );

        $('#account').val( e.taobaoList[0].acount )
        $('#receiver').val( e.taobaoList[0].receiver )
        $('#receiveMobile').val( e.taobaoList[0].receiveMobile )
        $('#receiveAddress').val( e.taobaoList[0].receiveAddress )
        $('#acountLevel').val(e.taobaoList[0].acountLevel)
        document.querySelector('#baitiaoStart').checked = e.taobaoList[0].baitiaoStart;

        $(`#choose-province`).val(`${e.taobaoList[0].receiveProvince}`);
        $("#choose-province select").trigger("change");
        $(`#choose-city`).val(`${e.taobaoList[0].receiveCity}`);
        $("#choose-city select").trigger("change");
        $(`#choose-district`).val(`${e.taobaoList[0].receiveCountry}`);

        $('#tb-account').attr('picurl',IMG_PREFIX+ e.taobaoList[0].mysiteImg).next().attr('src', IMG_PREFIX+e.taobaoList[0].mysiteImg)
        $('#tb-level').attr('picurl',IMG_PREFIX+ e.taobaoList[0].myacountImg).next().attr('src', IMG_PREFIX+e.taobaoList[0].myacountImg)
        $('#tb-huabei').attr('picurl',IMG_PREFIX+ e.taobaoList[0].baitiaoImg).next().attr('src', IMG_PREFIX+e.taobaoList[0].baitiaoImg)
    }

    // 审核中禁止修改
    if( e.taobaoList[0].approve === 0) {
        forzenTaobaoInfo()
    }

  }, null);
}


//绑定淘宝
function doBindTB() {
  if ( $('#account').val() === '' ) {
    notifyInfo('请填写淘宝账号');return;
  }

  if ( $('#receiver').val() === '' ) {
    notifyInfo('请填写收货人');return;
  }

  if ( $('#receiveMobile').val() === '' ) {
    notifyInfo('请填写收货人手机号');return;
  }

  if ( $('#receiveAddress').val() === '' ) {
    notifyInfo('请填写详细地址');return;
  }

  if ( $('#choose-province').val() === '' ) {
    notifyInfo('请选择收货省份');return;
  }

  if ( $('#choose-city').val() === '' ) {
    notifyInfo('请选择收货城市');return;
  }

  if ( $('#choose-district').val() === '' ) {
    notifyInfo('请选择收货区');return;
  }

  if ( typeof($('#tb-account').attr('picurl')) === 'undefined' ) {
    notifyInfo('请上传账号截图');return;
  }

  if ( typeof($('#tb-level').attr('picurl')) === 'undefined' ) {
    notifyInfo('请上传等级截图');return;
  }

  if ( typeof($('#tb-huabei').attr('picurl')) === 'undefined' ) {
    notifyInfo('请上传花呗情况截图');return;
  }

  var obj = {
    type: '淘宝',
    buyerId: cookie('id'),
    acount: $('#account').val(),
    acountLevel: $('#acountLevel').val(),
    baitiaoStart: (document.querySelector('#baitiaoStart').checked)?1:0,
    receiver: $('#receiver').val(),
    receiveMobile: $('#receiveMobile').val(),

    receiveProvince: $('#choose-province').val(),
    receiveCity: $('#choose-city').val(),
    receiveCountry: $('#choose-district').val(),
    receiveAddress: $('#receiveAddress').val(),

    mysiteImg: $('#tb-account').attr('picurl'),
    myacountImg: $('#tb-level').attr('picurl'),
    baitiaoImg: $('#tb-huabei').attr('picurl'),
  };


  promise('POST', URL_BUY_BIND_ACCOUNT, JSON.stringify(obj), function(e){
    // console.log(e);
    initUserInfo();
    notifyInfo('绑定淘宝账号成功！');
    $('#bind-tb-btn').hide();
    initBindTB()
  }, null);
}


//初始化实名认证
function initRealName() {
  console.log('realname');
  promise('GET', URL_BUY_INFO, null, function(e){
    // console.log(e);
    $('#approve-status span').text( e.approveStateSting );
    // 未审核
    if ( e.approveState === -1 ) return;

    // 审核不通过
    if ( e.approveState === 2) {
        $('ons-card#approve-reason').css('display', 'block');
        $('ons-card#approve-reason span').text(e.approveReason);
        $('#realName').val( e.name )
        $('#idCard').val( e.idcard )
        $('#up-card-f').attr('picurl',IMG_PREFIX+ e.idcardpng1).next().attr('src', IMG_PREFIX+e.idcardpng1)
        $('#up-card-b').attr('picurl',IMG_PREFIX+ e.idcardpng2).next().attr('src', IMG_PREFIX+e.idcardpng2)
    }

    // 审核中
    if ( e.approveState === 0) {
        $('#realName').val( e.name )
        $('#idCard').val( e.idcard )
        $('#up-card-f').attr('picurl',IMG_PREFIX+ e.idcardpng1).next().attr('src', IMG_PREFIX+e.idcardpng1)
        $('#up-card-b').attr('picurl',IMG_PREFIX+ e.idcardpng2).next().attr('src', IMG_PREFIX+e.idcardpng2)
        $('#realName').attr('readonly',true)
        $('#idCard').attr('readonly',true)
        $('#up-card-f').attr('disabled',true)
        $('#up-card-b').attr('disabled',true)
        $('#real-name-btn').hide()
    }

    // 审核通过
    if( e.approveState === 1) {
        $('#realName').val( e.name )
        $('#idCard').val( e.idcard )
        $('#up-card-f').attr('picurl',IMG_PREFIX+ e.idcardpng1).next().attr('src', IMG_PREFIX+e.idcardpng1)
        $('#up-card-b').attr('picurl',IMG_PREFIX+ e.idcardpng2).next().attr('src', IMG_PREFIX+e.idcardpng2)
        $('#realName').attr('readonly',true)
        $('#idCard').attr('readonly',true)
        $('#up-card-f').attr('disabled',true)
        $('#up-card-b').attr('disabled',true)
        $('#real-name-btn').hide()
    }
  }, null);
}


//实名认证
function doRealName() {
  if ( $('#realName').val() === '' ) {
    notifyInfo('请填写姓名！');return;
  }

  if ( $('#idCard').val() === '' ) {
    notifyInfo('请填写身份证号！');return;
  }

  if ( typeof($('#up-card-f').attr('picurl')) === 'undefined' ) {
    notifyInfo('请上传身份证正面照片！');return;
  }

  if ( typeof($('#up-card-b').attr('picurl')) === 'undefined' ) {
    notifyInfo('请上传身份证背面照片！');return;
  }

  var obj = {
    name: $('#realName').val(),
    idcard: $('#idCard').val(),
    idcardpng1: $('#up-card-f').attr('picurl'),
    idcardpng2: $('#up-card-b').attr('picurl'),
  };

  promise('POST', URL_BUY_BIND_ID_CARD, JSON.stringify(obj), function(e){
    initUserInfo();
    notifyInfo('绑定账号成功！');
    $('#real-name-btn').hide();
    initRealName()
  }, null);
}

//更新用户信息
function initUpdateBuyer() {
 var obj = [cookie('mobile'), cookie('name'), cookie('mobile'), cookie('qq'), cookie('weixin')];
  $('#update-buyer ons-input').each(function (index) {
      $(this).attr('value', obj[index]);
  });
}

function saveList(s, list) {
    var data = {};
    for(i=0; i<list.length; i++) {
      data[list[i]] = s[i];
    }
    return data;
}

function wechatSave() {
    var $l = ['id','name','mobile','qq','weixin'];
    var $s = [];
    $('#update-buyer ons-input').each(function (index) {
        $s[index] = $(this).val()
    });
    $s[0] = cookie('id');
    var data = saveList($s, $l);
    console.log(JSON.stringify(data));
    promise('POST',URL_BUY_UPDATE,JSON.stringify(data), cbSave, null);
}

function cbSave(e) {
    initUserInfo();
    initUpdateBuyer();
    notifyInfo(MSG_UPDATE_SUCCESS);
}


function forzenBankInfo() {
  $('#acountName').attr('readonly',true)
  $('#bank').attr('disabled',true)
  $('#acountSubbank').attr('readonly',true)
  $('#bankNo').attr('readonly',true)
  $('.group-remove').hide()
  $('#bind-card-btn').hide()
}

function UnforzenBankInfo() {
    $('#acountName').attr('readonly',false)
    $('#bank').attr('disabled',false)
    $('#acountSubbank').attr('readonly',false)
    $('#bankNo').attr('readonly',false)
    $('.group-remove').show()
    $('#bind-card-btn').show()
}

//初始化绑定银行卡
function initBindBank() {
  promise('GET', '/buyer/person_info', null, function(e){
    console.log(e);

    $('#acountName').attr('readonly',true);
    $('#acountName').val(e.name);
    $('#approve-status span').text( e.bankcardStateSting);

    if(e.approveState !== 1) {
        notifyInfo('请先绑定身份证！');
        return;
    }

    // 未绑定
    if ( e.bankcardState === -1) return;


    // 审核不通过
    if ( e.bankcardState === 2) {
        $('ons-card#approve-reason').css('display', 'block');
        $('ons-card#approve-reason span').text(e.bankcardApproveReason);
    }

    // 审核中 （银行卡没有审核）
    if ( e.bankcardState === 0) {
        $('#acountName').val( e.buyerBankList[e.buyerBankList.length - 1].acountName )
        $(`#bank option[value="${e.buyerBankList[e.buyerBankList.length - 1].bank}"]`)
        $('#acountSubbank').val( e.buyerBankList[e.buyerBankList.length - 1].acountSubbank )
        $('#bankNo').val( e.buyerBankList[e.buyerBankList.length - 1].bankNo )
    }

    // 审核通过
    if ( e.bankcardState === 1) {
        $('#acountName').val( e.buyerBankList[e.buyerBankList.length - 1].acountName )
        $(`#bank option[value="${e.buyerBankList[e.buyerBankList.length - 1].bank}"]`)
        $('#acountSubbank').val( e.buyerBankList[e.buyerBankList.length - 1].acountSubbank )
        $('#bankNo').val( e.buyerBankList[e.buyerBankList.length - 1].bankNo )
    }
  }, null);
}

//绑定银行卡
function doBindCard() {
  if ( $('#acountName').val() === '' ) {
    notifyInfo('请填写开户姓名！');return;
  }

  if ( $('#acountSubbank').val() === '' ) {
    notifyInfo('请填写开户行！');return;
  }

  if ( $('#bankNo').val() === '' ) {
    notifyInfo('请填写银行账号！');return;
  }

  if ( $('#bankNo').val() === '' ) {
    notifyInfo('请填写确认账号！');return;
  }

  if ( $('#reBankNo').val() === '' ) {
    notifyInfo('请填写确认账号！');return;
  }

  if ( !$.isNumeric($('#bankNo').val())) {
    notifyInfo('请填写正确的账号！');return;
  }

  if ( $('#bankNo').val() !== $('#reBankNo').val()) {
    notifyInfo('两次输入的账号不匹配！');return;
  }

  var obj = {
    acountName: $('#acountName').val(),
    bank: $('#bank').val(),
    acountSubbank: $('#acountSubbank').val(),
    bankNo: $('#bankNo').val(),
    acountBankno: '',
    buyerId: cookie('id')
  };

  promise('POST', URL_BUY_BIND_BANK, JSON.stringify(obj), function(e){
    initUserInfo();
    notifyInfo('绑定账号成功！');
    initBindBank()
  }, null);
}



// CONTACT_US FUNC
function copyQQ() {
    var clipboardA = new ClipboardJS('.copyQQ-a', {text: function () { return '2939085757'; }});
    var clipboardB = new ClipboardJS('.copyQQ-b', {text: function () { return '3173700944'; }});

    clipboardA.on('success', function () {notifyToast('复制成功！');});
    clipboardB.on('success', function () {notifyToast('复制成功！');});
}

// LIST FUNC
function listPushPage() {
    var pageId = $(this).attr('id') + '.html';
    navPushPage(pageId);
}

function myOrdersIndex(event) {
    var id = $(this).attr('id');
    document.querySelector('ons-tabbar#main-tabbar').setActiveTab(2, {
        callback: function () {
            document.querySelector('ons-tabbar#list-tabbar').setActiveTab(parseInt(id));
        }
    });
}

function myOrdersClick() {
    document.querySelector('ons-tabbar#main-tabbar').setActiveTab(2, {
        callback: function () {
            document.querySelector('ons-tabbar#list-tabbar').setActiveTab(5);
        }
    });
}